package com.ehome.poct.core.dao.mybatis;

import cn.hutool.core.bean.BeanUtil;
import com.ehome.mybatisplus.support.AbstractCrudRepository;
import com.ehome.poct.core.api.dto.check.gold.TestRecordDetailExtDTO;
import com.ehome.poct.core.dao.entity.check.TestRecordDetailExtDO;
import com.ehome.poct.core.dao.mybatis.mapper.TestRecordDetailExtMapper;
import com.ehome.poct.core.repository.check.TestRecordDetailExtRepository;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 检测记录扩展表RepositoryImpl
 *
 * @author ehome
 * @Date 2022-03-19 16:15
 */
@Repository
@AllArgsConstructor
public class TestRecordDetailExtRepositoryImpl extends AbstractCrudRepository<TestRecordDetailExtDO, TestRecordDetailExtDTO> implements TestRecordDetailExtRepository {
    private final TestRecordDetailExtMapper mapper;

    @Override
    public TestRecordDetailExtDTO getAgentInfo(Long agentId) {
        return mapper.getAgentInfo(agentId);
    }

    @Override
    public void batchSave(List<TestRecordDetailExtDTO> detailExtDTOList) {
        detailExtDTOList.forEach(detailExtDTO -> {
            mapper.insert(BeanUtil.copyProperties(detailExtDTO, TestRecordDetailExtDO.class));
        });
    }
}
